# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Contributor: Eric Timmons <etimmons@alum.mit.edu>
# Contributor: Will Sinatra <wpsinatra@gmail.com>
# Maintainer: Will Sinatra <wpsinatra@gmail.com>
pkgname=sbcl
pkgver=2.0.7
pkgrel=0
pkgdesc="Steel Bank Common Lisp"
url="http://www.sbcl.org/"
arch="x86 x86_64 armv7 aarch64"
license="custom"
options="!check"
checkdepends="ed"
makedepends="ecl ecl-dev gmp-dev gc gc-dev libffi-dev linux-headers paxmark zlib-dev"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.bz2::https://prdownloads.sourceforge.net/sbcl/sbcl-$pkgver-source.tar.bz2
	0004-Only-include-old-memcpy-version-on-glibc.patch
	Fix-ARM-build-using-ECL-host.patch
	march-armv5-removed.patch"

build() {
	all_arch_conf='--with-sb-test --with-sb-unicode --with-sb-core-compression'

	case "$CARCH" in
		armv7) conf="$all_arch_conf" ;;
		aarch64) ;;
		*) conf="$all_arch_conf --with-sb-thread" ;;
	esac

	GNUMAKE=make ./make.sh ecl --prefix=/usr $conf
}

package() {
	INSTALL_ROOT="$pkgdir/usr" \
		LIB_DIR="/usr/lib" \
		DOC_DIR="$pkgdir/usr/share/doc/$pkgname" \
		sh install.sh

	paxmark -rm "$pkgdir"/usr/bin/sbcl

	install -Dm644 COPYING \
		"$pkgdir"/usr/share/licenses/$pkgname/LICENSE.txt

	rmdir "$pkgdir"/usr/share/doc/sbcl/html \
		"$pkgdir"/usr/share/info 2>/dev/null || true
}

sha512sums="02f39a2d643e2aebfe0e96611a9bca7cd859ff8a64d0e552cb4e39697a72a69fc51eacf40388bb49d64d851ea4005f9098100e490001d028844d0e2adc3b1490  sbcl-2.0.7.tar.bz2
7c7d7b982814435463a7678ff59ab354426bcee62a3b7ba253d8da1391e68c614cd4d90970fbbfd68ea0927c2689b6c16f01b0e0185489329700ce21aaa5a92c  0004-Only-include-old-memcpy-version-on-glibc.patch
6f49d1f1c6bd4e8d839e6b4ab3bb74cbdcce85ee83a0f1c5efab04d97b613a624f8874dadd7f6d981940ff28c468f00b74a56ff2afc53f41884d753ac7a5028f  Fix-ARM-build-using-ECL-host.patch
367454a75de122134fdbf1064182a96ee00cf0685db0922134fdbdfc0e0bb2c6a5cfb9878f23409eca48a443e0f19b291f8d380e3475176a4c8cea0c9768c2bd  march-armv5-removed.patch"
